<template>
  <div>
    <!-- 新闻列表 -->
    <ul>
      <li
        @click="goDetail(news.art_id.toString())"
        v-for="news in list"
        :key="news.art_id.toString()"
      >
        {{news.title}}
      </li>
    </ul>
  </div>
</template>

<script>
import { mapActions, mapState } from 'vuex'
export default {
  created () {
    console.log(this.$store)
    // 调用vuex中action方法获取新闻列表数据
    this.getList()
  },
  computed: {
    // 获取vuex中list数据
    ...mapState(['list'])
  },
  methods: {
    ...mapActions(['getList']),
    // 跳转详情页
    goDetail (id) {
      console.log(id)
      this.$router.push(`/detail/${id}`)
    }
  }
}
</script>

<style  scoped>
</style>
